#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>

using namespace std;

int partsort1(int* a, int left, int right, int n)
{
	int key = a[left];
	int hole = left;
	while (left < right)
	{
		while (left < right && a[right] >= key)
			--right;
		a[hole] = a[right];
		hole = right;
		while (left < right && a[left] <= key)
			++left;
		a[hole] = a[left];
		hole = left;
	}
	a[hole] = key;
	for (int i = 0; i < n; i++)
	{
		cout << a[i];
		if (i < n - 1)
		{
			cout << ' ';
		}
	}
	cout << endl;
	return hole;
}

void Qsort(int* a, int left, int right, int n)
{
	if (left >= right)
		return;
	int keyi = partsort1(a, left, right, n);
	Qsort(a, left, keyi - 1, n);
	Qsort(a, keyi + 1, right, n);
}

void test2()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n;
		cin >> n;
		int* a = new int[n];
		for (int i = 0; i < n; i++)
		{
			cin >> a[i];
		}
		Qsort(a, 0, n - 1, n);
		if (t)
		{
			cout << endl;
		}
	}
}

int main()
{
	test2();
	return 0;
}
